import pandas as pd
import numpy as np


def shuffle(*arrs, seed=0):
    """ shuffle

    Shuffle 数据

    Arguments:
        *arrs: 数组数据

    Returns:
        shuffle后的数据

    """
    arrs = list(arrs)
    for i, arr in enumerate(arrs):
        assert len(arrs[0]) == len(arrs[i])
        arrs[i] = np.array(arr)
    np.random.seed(seed)
    p = np.random.permutation(len(arrs[0]))
    return tuple(arr[p] for arr in arrs)


df = pd.read_csv('data.csv')
print(df['label'].value_counts())
df_0 = df[df['label'] == 0].sample(frac=0.2)
df_2 = df[df['label'] == 2].sample(frac=0.5)
df_all = df[df['label'] == 1].append(df_0).append(df_2).append(df[df['label'] == 3]).append(df[df['label'] == 4])
print(df_all['label'].value_counts())
df_all.to_csv('parent_data.csv', index=False, encoding='utf_8_sig')
